Skip to content

Fix deadline serialization, repr, and prune edge cases - #70421

Open
seanghaeli wants to merge 5 commits into
apache:mainfrom
aws-mwaa:feature/deadline-robustness-followup
Open

Fix deadline serialization, repr, and prune edge cases#70421
seanghaeli wants to merge 5 commits into
apache:mainfrom
aws-mwaa:feature/deadline-robustness-followup

Conversation

@seanghaeli

@seanghaeli seanghaeli commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Split out of #68919 per review. Edge-case fixes in the deadline model and serialization paths:

  • Deserialization routes by __class_path ahead of reference_type (custom references can share a builtin's class name), and a reference with no importable __class_path raises a clear error instead of a KeyError.
  • __repr__ on Deadline and DeadlineAlert never raises (guards the dagrun relationship post-cascade-delete and the dict-shaped interval).
  • prune_deadlines excludes missed deadlines so a missed deadline's queued callback is not cascade-deleted.

Split out of apache#68919 per review: decoder __class_path routing, clear
error for missing __class_path, repr guards for severed dagrun and
dict-shaped interval, and prune guard for missed deadlines.
@seanghaeli seanghaeli changed the title Harden deadline serialization, repr, and prune paths Fix deadline serialization, repr, and prune edge cases Jul 24, 2026
@seanghaeli
seanghaeli marked this pull request as ready for review July 25, 2026 00:14
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 28, 2026
@seanghaeli
seanghaeli force-pushed the feature/deadline-robustness-followup branch from 09a9f50 to 385914d Compare July 28, 2026 22:32
custom_class = find_registered_custom_deadline_reference(reference_data["__class_path"])
class_path = reference_data.get("__class_path")
if not class_path:
raise ValueError(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better messaging. 👍

# specific language governing permissions and limitations
# under the License.
"""
Adversarial QA coverage for ``Deadline.prune_deadlines``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude comments?

Comment on lines +95 to +97
def setup_method():
_clean_db()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to clean the db before our tests, then something else is leaving artifacts that should not be there, this will hide issues.

if TYPE_CHECKING:
from sqlalchemy.orm import Session

DAG_ID = "qaw18_prune_dag"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"qaw18"??

Adversarial QA coverage for ``Deadline.prune_deadlines``.

``prune_deadlines`` is the batch-delete path the scheduler invokes (via
``DagRun.update_state`` -> ``dagrun.py:1237``) when a DagRun completes on time:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole docstring is odd, but the line number in particular is pretty pointless and will drift in no time, if it hasn't already.

def test_deadline_alert_repr_does_not_raise_on_json_dict_interval(
self, deadline_alert_orm, interval, expected
):
"""``DeadlineAlert.__repr__`` must never raise for the PRODUCTION (JSON-dict) ``interval`` shape.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, we don't generally have a novel for a test docstring when the test's name is usually pretty self-documenting.

Comment on lines +66 to +67
if isinstance(data, (int, float)):
interval_seconds = int(data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be safer to check if __classname__ == "datetime.timedelta" instead, otherwise I think this could catch a broader scope than intended. I may be overthinking this one though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:DAG-processing area:deadline-alerts AIP-86 (former AIP-57) ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants